<template>
    <div class="listDiv">
        <div class="searchDiv">
            <el-input clearable placeholder="匹配试卷名称" v-model="obj.req.key" class="search_key" />
            <span class="btn search" @click="init">搜索</span>
            <span class="btn refresh" @click="obj.req.currentpage=1;init()"></span>
            <div class="searchRight">
            </div>
        </div>
        <div class="table_box"><div class="table_" id="tb">
            <ul class="head">
                <li class="mw300">试卷名</li>
                <li class="wcen">总分</li>
                <li class="wcen">作答人数</li>
                <li class="wcen">平均分/实际</li>
                <li class="wcen">平均分/百分制</li>
                <li class="">操作</li>
            </ul>
            <div class="body">
                <ul v-for="x in obj.ary" :key="x">
                    <li class="mw300">
                        <el-tooltip class="box-item" effect="dark" :content="x.name" placement="top-start" :disabled="x.name.length<17">
                            <div class="lineOne pointer">{{x.name}}</div>
                        </el-tooltip>
                    </li>
                    <li class="wcen">{{parseInt(x.cou)}}</li>
                    <li class="wcen">{{parseInt(x.fen)}}</li>
                    <li class="wcen">{{(+x.avgfen).toFixed(2)}}</li>
                    <li class="wcen">{{x.fen?(((+x.avgfen)/x.fen)*100).toFixed(0):'--'}}</li>
                    <li class="">
                        <el-button class="read_btn" type="primary" @click="edit(x)">查看</el-button>
                    </li>
                </ul>
            </div>
        </div>
        </div><Pager :value="obj.req" :init="init" />

        <el-dialog v-model="obj.drawer.design" :title="obj.drawer.designTitle" width="1000px" :close-on-click-modal="false" :destroy-on-close="true">
            <router-view @close="obj.drawer.design = false" @init="init" />
        </el-dialog>
    </div>
</template>

<script setup>
    import { reactive, getCurrentInstance, ref, toRefs, provide, computed } from 'vue'
    import Pager from '@/components/pager.vue'
    import DelConfirm from '@/components/del_confirm.vue'
    let { proxy } = getCurrentInstance()

    let obj = reactive({
        drawer: {
            design: false,
            designTitle: "",
        },
        ary: [],
        req: {
            currentpage: 1,
            pagesize: 10,
            count: 0,
            key: "",
        }
    });
    let init = () => {
        proxy.$ajax({
            url: '/evaluation_statistics/list',
            data: obj.req,
            bfLoading: true
        }).then(d => {
            // console.log(d)
            if(d.success){
                obj.ary = d.msg.list
                obj.req.count = d.msg.count
            }
        }).catch(() => { })
    }

    let editId = ref(0)
    provide("id", editId); //不能加.value
    let edit = x => {
        obj.drawer.design = true
        obj.drawer.designTitle = "试卷答题详情统计"
        editId.value = x.paper_id;
    }
</script>

<style scoped>
    ::-webkit-scrollbar { width:10px; background-color: #FFFFFF; }
    .search_select { width:100px!important; }
    .search_key { width:160px!important; }
    #tb ul li.li2 { width: 60px; }
    #tb ul li.li3 { width: 60px; }
    #tb ul li.li4 { width: 45px; }
</style>